﻿using System;
using System.Diagnostics;
using System.Windows.Forms;
using SF.Code.Extension.WinAPI;
using SG.Productivity.DesktopControlPanel.Controls;
using SG.Productivity.DesktopControlPanel.Support;

namespace SG.Productivity.DesktopControlPanel
{
    static class Program
    {

        public static readonly string DefaultAddress = Debugger.IsAttached ? "win8dev:3000" : "localhost";

        public static void RunAsConsole()
        {
            Kernel32.EnsureConsole();
            Console.WriteLine("Attached to parent");

            if (Kernel32.KeepConsoleOpen)
            {
                Console.WriteLine("Press any key to exit...");
                Console.Read();
            }
        }


        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            if (args != null && args.Length > 0)
            {
                RunAsConsole();
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new TopPanel());

                Application.ApplicationExit += TerminateFunction;
            }
        }
           
        static void TerminateFunction(object sender, EventArgs e)
        {
            MouseHookHelper.Unregister();
        }
    }
}
